#include<bits/stdc++.h>
using namespace std;
stack<int>sta;
stack<int>stb;
stack<int>stk;
int main(){
	freopen("dishes.in" , "r" , stdin);
	freopen("dishes.out" , "w" , stdout);
	int n;
	cin >> n;
	for(int i = n ; i >= 1 ; i--){
		sta.push(i);
	}
	int flag = 0 , k , i = 0 , c;
	while(cin >> k >> c){
		i++;
		flag++;
		if(k == 1){
			for(int j = 1 ; j <= c ; j++){
				stb.push(sta.top());
				sta.pop();
			}
		}
		else if(k == 2){
			for(int j = 1 ; j <= c ; j++){
				stk.push(stb.top());
				stb.pop();
			}
		}
		
		if(sta.empty() && stb.empty()){
			break;
		}
	}
	for(int i = 1 ; i <= n ; i++){
		cout << stk.top() << endl;
		stk.pop();
	}
	return 0;
}